package cn.echoedu.specifics;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import cn.echoedu.daoconstants.QueryType;
import cn.echoedu.daoconstants.TableName;
import cn.echoedu.entity.AClass;
import cn.echoedu.entity.AppApi;
import cn.echoedu.entity.ClassNotify;
import cn.echoedu.entity.ClassNotifyImage;
import cn.echoedu.entity.Degress;
import cn.echoedu.entity.Department;
import cn.echoedu.entity.HomePageImage;
import cn.echoedu.entity.Image;
import cn.echoedu.entity.JobAuthority;
import cn.echoedu.entity.PoliticalStatus;
import cn.echoedu.entity.Professional;
import cn.echoedu.entity.ReceiveClassNotify;
import cn.echoedu.entity.ReceiveSchoolNotify;
import cn.echoedu.entity.RequestMessage;
import cn.echoedu.entity.School;
import cn.echoedu.entity.SchoolCalendar;
import cn.echoedu.entity.SchoolNotify;
import cn.echoedu.entity.SchoolNotifyImage;
import cn.echoedu.entity.Student;
import cn.echoedu.entity.Teacher;
import cn.echoedu.entity.TelContacts;
import cn.echoedu.entity.User;
import cn.echoedu.util.L;

/**
 * ��װ��ݿ����
 * @author Administrator
 *
 */
public class SpecMySql {
	private final static String T="MySqlSpecifics-------->";

	private static SpecStudent specstudent = new SpecStudent();
	private static SpecTeacher specteacher = new SpecTeacher();
	private static SpecUser specuser = new SpecUser();
	private static SpecFeedBack specFeedBack = new SpecFeedBack();
	private static SpecTelContacts spetelcontacts = new SpecTelContacts();
	private static SpecImage specimage = new SpecImage();
	private static SpecRequestMessage specrequestmessage = new SpecRequestMessage();
	private static SpecHomePageImage spechomepageimage = new SpecHomePageImage();
	private static SpecAppApi specappapi = new SpecAppApi();
	private static SpecDegress specdegress = new SpecDegress();
	private static SpecAClass specaclass = new SpecAClass();
	private static SpecPoliticalStatus specpolitical = new SpecPoliticalStatus();
	private static SpecJobAuthority specjobauthority = new SpecJobAuthority();
	private static SpecSchoolNotify specschoolnotify = new SpecSchoolNotify();
	private static SpecSchoolNotifyImage specschoolnotifyimage = new SpecSchoolNotifyImage();
	private static SpecReceiveSchoolNotify specreceiveschoolnotify =
			new SpecReceiveSchoolNotify();
	private static SpecProfessional specprofessional = new SpecProfessional();
	private static SpecClassNotify specclassnotify = new SpecClassNotify();
	private static SpecClassNotifyImage specclassnotifyimage = new SpecClassNotifyImage();
	private static SpecReceiveClassNotify specreceiveclassnotify = 
			new SpecReceiveClassNotify();
	private static SpecSchool specschool = new SpecSchool();
	private static SpecSchoolCalendar specschoolcalendar = new SpecSchoolCalendar();
	private static SpecDepartment specdepartment = new SpecDepartment();
	public static String queryString(TableName tableName,String primaryKey,QueryType
			type){
		L.p(T+"queryString");
		StringBuffer firstHalf=new StringBuffer();
		switch (type){
		case READ:
			firstHalf.append("select * from "+tableName+" where ");
			break;
		case DELETE:
			firstHalf.append("DELETE from " +tableName+" where ");
			break;
		default:
		}



		switch (tableName){
		case STUDENT_TABLE:
			firstHalf.append("studentnumber='");
			break;
		case TEL_CONTACTS_TABLE:
			firstHalf.append("contactsid='");
			break;
		case IMAGE_TABLE:
			firstHalf.append("imageid='");
			break;
		case REQUEST_MESSAGE_TABLE:
			firstHalf.append("requestmessageid='");
			break;
		case HOMEPAGE_IMAGE_TABLE:
			firstHalf.append("homepageimageid='");
			break;
		case USER_TABLE:
			firstHalf.append("usernumber='");
			break;
		case TEACHER_TABLE:
			firstHalf.append("teachernumber='");
			break;
		case APPAPI_TABLE:
			firstHalf.append("appapiid='");
			break;
		case DEGRESS_TABLE:
			firstHalf.append("degressid='");
			break;
		case ACLASS_TABLE:
			firstHalf.append("classcode='");
			break;
		case POLITICAL_STATUS_TABLE:
			firstHalf.append("politicalstatuscode='");
			break;
		case JOB_AUTHORITY_TABLE:
			firstHalf.append("jobauthorityid='");
			break;
		case SCHOOL_NOTIFY_TABLE:
			firstHalf.append("schoolnotifyid='");
			break;
		case SCHOOL_NOTIFY_IMAGE_TABLE:
			firstHalf.append("schoolnotifyimageid='");
			break;
		case RECEIVE_SCHOOL_NOTIFY_TABLE:
			firstHalf.append("receivenotifyid='");
			break;
		case PROFESSIONAL_TABLE:
			firstHalf.append("professionalcode='");
			break;
		case CLASS_NOTIFY_TABLE:
			firstHalf.append("classnotifyid='");
			break;
		case CLASS_NOTIFY_IMAGE_TABLE:
			firstHalf.append("classnotifyimageid='");
			break;
		case RECEIVE_CLASS_NOTIFY_TABLE:
			firstHalf.append("receiveclassnotifyid='");
			break;
		case SCHOOL_TABLE:
			firstHalf.append("schoolcode='");
			break;
		case DEPARTMENT_TABLE:
			firstHalf.append("departmentcode='");
			break;
		case SCHOOL_CALENDAR:
			firstHalf.append("schoolcalendarid='");
			break;
		default:
			return null;
		}
		String lastHalf=primaryKey+"'";


		return firstHalf.append(lastHalf).toString();
	}
	public static <T> String getPrimaryKey(TableName tableName,T currentPojo){
		switch (tableName){
		case STUDENT_TABLE:
			return ((Student)currentPojo).getStudentnumber()+"";
		case TEL_CONTACTS_TABLE:
			return ((TelContacts)currentPojo).getContactsid()+"";
		case IMAGE_TABLE:
			return ((Image)currentPojo).getImageid()+"";
		case REQUEST_MESSAGE_TABLE:
			return ((RequestMessage)currentPojo).getRequestmessageid()+"";
		case HOMEPAGE_IMAGE_TABLE:
			return ((HomePageImage)currentPojo).getHomepageimageid()+"";
		case USER_TABLE:
			return ((User)currentPojo).getUsernumber()+"";
		case TEACHER_TABLE:
			return ((Teacher)currentPojo).getTeachernumber()+"";
		case APPAPI_TABLE:
			return ((AppApi)currentPojo).getAppapiid()+"";
		case DEGRESS_TABLE:
			return ((Degress)currentPojo).getDegressid()+"";
		case ACLASS_TABLE:
			return ((AClass)currentPojo).getClasscode()+"";
		case POLITICAL_STATUS_TABLE:
			return ((PoliticalStatus)currentPojo).getPoliticalstatuscode()+"";
		case JOB_AUTHORITY_TABLE:
			return ((JobAuthority)currentPojo).getJobauthorityid()+"";
		case SCHOOL_NOTIFY_TABLE:
			return ((SchoolNotify)currentPojo).getSchoolnotifyid()+"";
		case SCHOOL_NOTIFY_IMAGE_TABLE:
			return ((SchoolNotifyImage)currentPojo).getSchoolnotifyimageid()+"";
		case RECEIVE_SCHOOL_NOTIFY_TABLE:
			return ((ReceiveSchoolNotify)currentPojo).getRecivenotify()+"";
		case PROFESSIONAL_TABLE:
			return ((Professional)currentPojo).getProfessionalcode()+"";
		case CLASS_NOTIFY_TABLE:
			return ((ClassNotify)currentPojo).getClassnotify()+"";
		case CLASS_NOTIFY_IMAGE_TABLE:
			return ((ClassNotifyImage)currentPojo).getClassnotifyimageid()+"";
		case RECEIVE_CLASS_NOTIFY_TABLE:
			return ((ReceiveClassNotify)currentPojo).getReceiveclassnotifyid()+"";
		case SCHOOL_TABLE:
			return ((School)currentPojo).getSchoolcode()+"";
		case DEPARTMENT_TABLE:
			return ((Department)currentPojo).getDepartmentcode()+"";
		case SCHOOL_CALENDAR:
			return ((SchoolCalendar)currentPojo).getSchoolcalendarid()+"";
		default:
			return null;
		}
	}
	/**
	 * 
	 * @param con the Connection Object
	 * @param tableName  tablename from TableName class
	 * @param currentPojo the info needed to be inserted
	 * @param running determine whether the id need to be inserted if true 
	 * represented needed
	 * @return
	 * @throws SQLException
	 */
	public static<T> PreparedStatement getPreparedInsert(Connection con,TableName
			tableName,T currentPojo,boolean running)throws SQLException{
		L.p(T+"getPreparedInsert*************************"+"\ncon:"+con
				+"\ntableName"+tableName
				+"\n currentPojo:"+currentPojo+"\nrunning:"+running+"\n**********");

		switch (tableName){
		case STUDENT_TABLE:
			if(running){
				return specstudent.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specstudent.getPreparedInsert(con, tableName, currentPojo);
			}
		case FEED_BACK:
			return specFeedBack.addFeedBack(con, tableName, currentPojo);
		case TEL_CONTACTS_TABLE:
			if(running){
				return spetelcontacts.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return spetelcontacts.getPreparedInsert(con, tableName,
						currentPojo);
			}
		case IMAGE_TABLE:
			if(running){
				return specimage.getPreparedInsertRunning(con, tableName, 
						currentPojo);
			}else{
				return specimage.getPreparedInsert(con, tableName, currentPojo);
			}
		case REQUEST_MESSAGE_TABLE:
			if(running){
				return specrequestmessage.getPreparedInsertRunning(con,
						tableName, currentPojo);
			}else{
				return specrequestmessage.getPreparedInsert(con, tableName,
						currentPojo);
			}
		case HOMEPAGE_IMAGE_TABLE:
			if(running){
				return spechomepageimage.getPreparedInsertRunning(con, 
						tableName, currentPojo);
			}else{
				return spechomepageimage.getPreparedInsert(con, tableName,
						currentPojo);
			}
		case USER_TABLE:
			if(running){
				return specuser.getPreparedInsertRunning(con, tableName, 
						currentPojo);
			}else{
				return specuser.getPreparedInsert(con, tableName, currentPojo);
			}
		case TEACHER_TABLE:
			if(running){
				return specteacher.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specteacher.getPreparedInsert(con, tableName, currentPojo);
			}
		case APPAPI_TABLE:
			if(running){
				return specappapi.getPreparedInsertRunning(con, tableName, 
						currentPojo);
			}else{
				return specappapi.getPreparedInsert(con, tableName, currentPojo);
			}
		case DEGRESS_TABLE:
			if(running){
				return specdegress.getPreparedInsertRunning(con, tableName, 
						currentPojo);
			}else{
				return specdegress.getPreparedInsert(con, tableName, currentPojo);
			}
		case ACLASS_TABLE:
			if(running){
				return specaclass.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specaclass.getPreparedInsert(con, tableName, currentPojo);
			}
		case POLITICAL_STATUS_TABLE:
			if(running){
				return specpolitical.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specpolitical.getPreparedInsert(con, tableName, 
						currentPojo);
			}
		case JOB_AUTHORITY_TABLE:
			if(running){
				return specjobauthority.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specjobauthority.getPreparedInsert(con, tableName, 
						currentPojo);
			}
		case SCHOOL_NOTIFY_TABLE:
			if(running){
				return specschoolnotify.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specschoolnotify.getPreparedInsert(con, tableName, 
						currentPojo);
			}
		case SCHOOL_NOTIFY_IMAGE_TABLE:
			if(running){
				return specschoolnotifyimage.getPreparedInsertRunning(con, 
						tableName, currentPojo);
			}else{
				return specschoolnotifyimage.getPreparedInsert(con, tableName,
						currentPojo);
			}
		case RECEIVE_SCHOOL_NOTIFY_TABLE:
			if(running){
				return specreceiveschoolnotify.getPreparedInsertRunning(con, 
						tableName, currentPojo);
			}else{
				return specreceiveschoolnotify.getPreparedInsert(con, tableName,
						currentPojo);
			}
		case PROFESSIONAL_TABLE:
			if(running){
				return specprofessional.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specprofessional.getPreparedInsert(con, tableName,
						currentPojo);
			}

		case CLASS_NOTIFY_TABLE:
			if(running){
				return specclassnotify.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specclassnotify.getPreparedInsert(con, tableName, 
						currentPojo);
			}
		case CLASS_NOTIFY_IMAGE_TABLE:
			if(running){
				return specclassnotifyimage.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specclassnotifyimage.getPreparedInsert(con, tableName, 
						currentPojo);
			}
		case RECEIVE_CLASS_NOTIFY_TABLE:
			if(running){
				return specreceiveclassnotify.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specreceiveclassnotify.getPreparedInsert(con, tableName, 
						currentPojo);
			}
		case SCHOOL_TABLE:
			if(running){
				return specschool.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specschool.getPreparedInsert(con, tableName, 
						currentPojo);
			}
		case DEPARTMENT_TABLE:
			if(running){
				return specdepartment.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specdepartment.getPreparedInsert(con, tableName, 
						currentPojo);
			} 
		case SCHOOL_CALENDAR:
			if(running){
				return specschoolcalendar.getPreparedInsertRunning(con, tableName,
						currentPojo);
			}else{
				return specschoolcalendar.getPreparedInsert(con, tableName, 
						currentPojo);
			} 
			 
		default:
			return null;
		}
	}
//	
	/**
	 * 
	 * @param con the Connection Object
	 * @param tableName  tablename from TableName class
	 * @param currentPojo the info needed to be inserted
	 * @param running determine whether the id need to be inserted if true 
	 * represented needed
	 * @return
	 * @throws SQLException
	 */
	public static<T> PreparedStatement getPreparedListInsert(Connection con,TableName
			tableName,T currentListPojo,boolean running)throws SQLException{
		//		L.p(T+"getPreparedInsert*************************"+"\ncon:"+con
		//				+"\ntableName"+tableName
		//				+"\n currentPojo:"+currentPojo+"\nrunning:"+running+"\n**********");

		switch (tableName){
		case STUDENT_TABLE:
			if(running){
				return specstudent.getPreparedInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specstudent.getPreparedListInsert(con, tableName, currentListPojo);
			}
		case FEED_BACK:
			return specFeedBack.addFeedBack(con, tableName, currentListPojo);
		case TEL_CONTACTS_TABLE:
			if(running){
				return spetelcontacts.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return spetelcontacts.getPreparedListInsert(con, tableName,
						currentListPojo);
			}
		case IMAGE_TABLE:
			if(running){
				return specimage.getPreparedListInsertRunning(con, tableName, 
						currentListPojo);
			}else{
				return specimage.getPreparedListInsert(con, tableName, currentListPojo);
			}
		case REQUEST_MESSAGE_TABLE:
			if(running){
				return specrequestmessage.getPreparedListInsertRunning(con,
						tableName, currentListPojo);
			}else{
				return specrequestmessage.getPreparedListInsert(con, tableName,
						currentListPojo);
			}
		case HOMEPAGE_IMAGE_TABLE:
			if(running){
				return spechomepageimage.getPreparedListInsertRunning(con, 
						tableName, currentListPojo);
			}else{
				return spechomepageimage.getPreparedListInsert(con, tableName,
						currentListPojo);
			}
		case USER_TABLE:
			if(running){
				return specuser.getPreparedListInsertRunning(con, tableName, 
						currentListPojo);
			}else{
				return specuser.getPreparedListInsert(con, tableName, currentListPojo);
			}
		case TEACHER_TABLE:
			if(running){
				return specteacher.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specteacher.getPreparedListInsert(con, tableName, currentListPojo);
			}
		case APPAPI_TABLE:
			if(running){
				return specappapi.getPreparedListInsertRunning(con, tableName, 
						currentListPojo);
			}else{
				return specappapi.getPreparedListInsert(con, tableName, currentListPojo);
			}
		case DEGRESS_TABLE:
			if(running){
				return specdegress.getPreparedListInsertRunning(con, tableName, 
						currentListPojo);
			}else{
				return specdegress.getPreparedListInsert(con, tableName, currentListPojo);
			}
		case ACLASS_TABLE:
			if(running){
				return specaclass.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specaclass.getPreparedListInsert(con, tableName, currentListPojo);
			}
		case POLITICAL_STATUS_TABLE:
			if(running){
				specpolitical.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specpolitical.getPreparedListInsert(con, tableName, 
						currentListPojo);
			}
		case JOB_AUTHORITY_TABLE:
			if(running){
				return specjobauthority.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specjobauthority.getPreparedListInsert(con, tableName, 
						currentListPojo);
			}
		case SCHOOL_NOTIFY_TABLE:
			if(running){
				return specschoolnotify.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specschoolnotify.getPreparedListInsert(con, tableName, 
						currentListPojo);
			}
		case SCHOOL_NOTIFY_IMAGE_TABLE:
			if(running){
				return specschoolnotifyimage.getPreparedListInsertRunning(con, 
						tableName, currentListPojo);
			}else{
				return specschoolnotifyimage.getPreparedListInsert(con, tableName,
						currentListPojo);
			}
		case RECEIVE_SCHOOL_NOTIFY_TABLE:
			if(running){
				return specreceiveschoolnotify.getPreparedListInsertRunning(con, 
						tableName, currentListPojo);
			}else{
				return specreceiveschoolnotify.getPreparedListInsert(con, tableName,
						currentListPojo);
			}
		case PROFESSIONAL_TABLE:
			if(running){
				return specprofessional.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specprofessional.getPreparedListInsert(con, tableName,
						currentListPojo);
			}

		case CLASS_NOTIFY_TABLE:
			if(running){
				return specclassnotify.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specclassnotify.getPreparedListInsert(con, tableName, 
						currentListPojo);
			}
		case CLASS_NOTIFY_IMAGE_TABLE:
			if(running){
				return specclassnotifyimage.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specclassnotifyimage.getPreparedListInsert(con, tableName, 
						currentListPojo);
			}
		case RECEIVE_CLASS_NOTIFY_TABLE:
			if(running){
				return specreceiveclassnotify.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specreceiveclassnotify.getPreparedListInsert(con, tableName, 
						currentListPojo);
			}
		case SCHOOL_TABLE:
			if(running){
				return specschool.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specschool.getPreparedListInsert(con, tableName, 
						currentListPojo);
			}
		case DEPARTMENT_TABLE:
			if(running){
				return specdepartment.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specdepartment.getPreparedInsert(con, tableName, 
						currentListPojo);
			} 
//			specschoolcalendar
		case SCHOOL_CALENDAR:
			if(running){
				return specschoolcalendar.getPreparedListInsertRunning(con, tableName,
						currentListPojo);
			}else{
				return specschoolcalendar.getPreparedInsert(con, tableName, 
						currentListPojo);
			} 
		default:
			return null;
		}
	}
	@SuppressWarnings("unchecked")
	public static<T> T getPreparedInsertGetPrimaryKey(Connection con,TableName
			tableName,T currentListPojo)throws SQLException{
		switch (tableName){
		case STUDENT_TABLE:
			return (T)specstudent.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case TEL_CONTACTS_TABLE:
			return (T)spetelcontacts.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case IMAGE_TABLE:
			return (T)specimage.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case REQUEST_MESSAGE_TABLE:
			return (T)specrequestmessage.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case HOMEPAGE_IMAGE_TABLE:
			return (T)spechomepageimage.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case USER_TABLE:
			return (T)specuser.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case TEACHER_TABLE:
			return (T)specteacher.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case APPAPI_TABLE:
			return (T)specappapi.getPreparedInsertGetPrimaryKeySql(con,
					tableName, currentListPojo);
		case DEGRESS_TABLE:
			return (T)specdegress.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case ACLASS_TABLE:
			return (T)specaclass.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case POLITICAL_STATUS_TABLE:
			return (T)specpolitical.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case JOB_AUTHORITY_TABLE:
			return (T)specjobauthority.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case SCHOOL_NOTIFY_TABLE:
			return (T)specschoolnotify.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case SCHOOL_NOTIFY_IMAGE_TABLE:
			return (T)specschoolnotifyimage.getPreparedInsertGetPrimaryKeySql(con,
					tableName, currentListPojo);
		case RECEIVE_SCHOOL_NOTIFY_TABLE:
			return (T)specreceiveschoolnotify.getPreparedInsertGetPrimaryKeySql(
					con, tableName, currentListPojo);
		case PROFESSIONAL_TABLE:
			return (T)specprofessional.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case CLASS_NOTIFY_TABLE:
			return (T)specclassnotify.getPreparedInsertGetPrimaryKeySql(con, 
					tableName, currentListPojo);
		case CLASS_NOTIFY_IMAGE_TABLE:
			return (T)specclassnotifyimage.getPreparedInsertGetPrimaryKeySql(con,
					tableName, currentListPojo);
		case RECEIVE_CLASS_NOTIFY_TABLE:
			return (T)specreceiveclassnotify.getPreparedInsertGetPrimaryKeySql(
					con, tableName, currentListPojo);
		case SCHOOL_TABLE:
			return (T)specschool.getPreparedInsertGetPrimaryKeySql(con,
					tableName, currentListPojo);
		case DEPARTMENT_TABLE:
			return (T)specdepartment.getPreparedInsertGetPrimaryKeySql(con,
					tableName, currentListPojo);
//			specschoolcalendar
		case SCHOOL_CALENDAR:
			return (T)specschoolcalendar.getPreparedInsertGetPrimaryKeySql(con,
					tableName, currentListPojo);
		default:
			return null;
		}


	}
	@SuppressWarnings("unchecked")
	public static<T> T getPojoFromResultSet(TableName tableName,ResultSet rs) 
			throws SQLException{
		final String M = "getPojoFromResultSet**********";
		L.p(T+M+tableName);
		switch (tableName){
		case STUDENT_TABLE:
			return (T)specstudent.getPojo(rs);
		case SCHOOL_CALENDAR:
			return (T)specschoolcalendar.getPojo(rs);
		case TEL_CONTACTS_TABLE:
			return (T)spetelcontacts.getPojo(rs);
		case IMAGE_TABLE:
			return (T)specimage.getPojo(rs);
		case REQUEST_MESSAGE_TABLE:
			return (T)specrequestmessage.getPojo(rs);
		case HOMEPAGE_IMAGE_TABLE:
			return (T)spechomepageimage.getPojo(rs);
		case USER_TABLE:
			return (T)specuser.getPojo(rs);
		case TEACHER_TABLE:
			return (T)specteacher.getPojo(rs);
		case APPAPI_TABLE:
			return (T)specappapi.getPojo(rs);
		case DEGRESS_TABLE:
			return (T)specdegress.getPojo(rs);
		case ACLASS_TABLE:
			return (T)specaclass.getPojo(rs);
		case POLITICAL_STATUS_TABLE:
			return (T)specpolitical.getPojo(rs);
		case JOB_AUTHORITY_TABLE:
			return (T)specjobauthority.getPojo(rs);
		case SCHOOL_NOTIFY_TABLE:
			return (T)specschoolnotify.getPojo(rs);
		case SCHOOL_NOTIFY_IMAGE_TABLE:
			return (T)specschoolnotifyimage.getPojo(rs);
		case RECEIVE_SCHOOL_NOTIFY_TABLE:
			return (T)specreceiveschoolnotify.getPojo(rs);
		case PROFESSIONAL_TABLE:
			return (T)specprofessional.getPojo(rs);
		case CLASS_NOTIFY_TABLE:
			return (T)specclassnotify.getPojo(rs);
		case CLASS_NOTIFY_IMAGE_TABLE:
			return (T)specclassnotifyimage.getPojo(rs);
		case RECEIVE_CLASS_NOTIFY_TABLE:
			return (T)specreceiveclassnotify.getPojo(rs);
		case SCHOOL_TABLE:
			return (T)specschool.getPojo(rs);
		case DEPARTMENT_TABLE:
			return (T)specdepartment.getPojo(rs);
//			
		
		default:
			return null;
		}
	}
	@SuppressWarnings("unchecked")
	public static<T> T getPojoFromLeftResultSet(TableName lefttableName,ResultSet rs) 
			throws SQLException{
		switch (lefttableName){
		case STUDENT_TABLE:
			return (T)specstudent.getLeftJoinPojo(rs);
		case TEL_CONTACTS_TABLE:
			return (T)spetelcontacts.getLeftJoinPojo(rs);
		case IMAGE_TABLE:
			return (T)specimage.getLeftJoinPojo(rs);
		case REQUEST_MESSAGE_TABLE:
			return (T)specrequestmessage.getLeftJoinPojo(rs);
		case HOMEPAGE_IMAGE_TABLE:
			return (T)spechomepageimage.getLeftJoinPojo(rs);
		case USER_TABLE:
			return (T)specuser.getLeftJoinPojo(rs);
		case TEACHER_TABLE:
			return (T)specteacher.getLeftJoinPojo(rs);
		case DEGRESS_TABLE:
			return (T)specdegress.getLeftJoinPojo(rs);
		case ACLASS_TABLE:
			return (T)specaclass.getLeftJoinPojo(rs);
		case POLITICAL_STATUS_TABLE:
			return (T)specpolitical.getLeftJoinPojo(rs);
		case JOB_AUTHORITY_TABLE:
			return (T)specjobauthority.getLeftJoinPojo(rs);
		case SCHOOL_NOTIFY_TABLE:
			return (T)specschoolnotify.getLeftJoinPojo(rs);
		case SCHOOL_NOTIFY_IMAGE_TABLE:
			return (T)specschoolnotifyimage.getLeftJoinPojo(rs);
		case RECEIVE_SCHOOL_NOTIFY_TABLE:
			return (T)specreceiveschoolnotify.getLeftJoinPojo(rs);
		case PROFESSIONAL_TABLE:
			return (T)specprofessional.getLeftJoinPojo(rs);
		case CLASS_NOTIFY_TABLE:
			return (T)specclassnotify.getLeftJoinPojo(rs);
		case CLASS_NOTIFY_IMAGE_TABLE:
			return (T)specclassnotifyimage.getLeftJoinPojo(rs);
		case RECEIVE_CLASS_NOTIFY_TABLE:
			return (T)specreceiveclassnotify.getLeftJoinPojo(rs);
		case SCHOOL_TABLE:
			return (T)specschool.getLeftJoinPojo(rs);
		case DEPARTMENT_TABLE:
			return (T)specdepartment.getLeftJoinPojo(rs);
		case SCHOOL_CALENDAR:
			return (T)specschoolcalendar.getLeftJoinPojo(rs);
		default:
			return null;
		}
	}
//	
	public static<T> PreparedStatement getPreparedUpdate(Connection con,
			TableName tableName,T oldPojo,T currentPojo)throws SQLException{
		switch (tableName){
		case STUDENT_TABLE:
			return specstudent.getPreparedUpdate(con,tableName,oldPojo,currentPojo);
		case TEL_CONTACTS_TABLE:
			return spetelcontacts.getPreparedUpdate(con, tableName, oldPojo,
					currentPojo);
		case IMAGE_TABLE:
			return specimage.getPreparedUpdate(con, tableName, oldPojo,
					currentPojo);
		case REQUEST_MESSAGE_TABLE:
			return specrequestmessage.getPreparedUpdate(con, tableName, oldPojo, 
					currentPojo);
		case HOMEPAGE_IMAGE_TABLE:
			return spechomepageimage.getPreparedUpdate(con, tableName, oldPojo,
					currentPojo);
		case USER_TABLE:
			return specuser.getPreparedUpdate(con, tableName, oldPojo, currentPojo);
		case TEACHER_TABLE:
			return specteacher.getPreparedUpdate(con, tableName, oldPojo,
					currentPojo);
		case APPAPI_TABLE:
			return specappapi.getPreparedUpdate(con, tableName, oldPojo,
					currentPojo);
		case DEGRESS_TABLE:
			return specdegress.getPreparedUpdate(con, tableName, oldPojo, 
					currentPojo);
		case ACLASS_TABLE:
			return specaclass.getPreparedUpdate(con, tableName, oldPojo,
					currentPojo);
		case POLITICAL_STATUS_TABLE:
			return specpolitical.getPreparedUpdate(con, tableName, oldPojo, 
					currentPojo);
		case JOB_AUTHORITY_TABLE:
			return specjobauthority.getPreparedUpdate(con, tableName, oldPojo,
					currentPojo);
		case SCHOOL_NOTIFY_TABLE:
			return specschoolnotify.getPreparedUpdate(con, tableName, oldPojo,
					currentPojo);
		case SCHOOL_NOTIFY_IMAGE_TABLE:
			return specschoolnotifyimage.getPreparedUpdate(con, tableName, 
					oldPojo, currentPojo);
		case RECEIVE_SCHOOL_NOTIFY_TABLE:
			return specreceiveschoolnotify.getPreparedUpdate(con, tableName, 
					oldPojo, currentPojo);
		case PROFESSIONAL_TABLE:
			return specprofessional.getPreparedUpdate(con, tableName, oldPojo, 
					currentPojo);
		case CLASS_NOTIFY_TABLE:
			return specclassnotify.getPreparedUpdate(con, tableName, oldPojo, 
					currentPojo);
		case CLASS_NOTIFY_IMAGE_TABLE:
			return specclassnotifyimage.getPreparedUpdate(con, tableName,
					oldPojo, currentPojo);
		case RECEIVE_CLASS_NOTIFY_TABLE:
			return specreceiveclassnotify.getPreparedUpdate(con, tableName,
					oldPojo, currentPojo);
		case SCHOOL_TABLE:
			return specschool.getPreparedUpdate(con, tableName,
					oldPojo, currentPojo);
		case DEPARTMENT_TABLE:
			return specdepartment.getPreparedUpdate(con, tableName,
					oldPojo, currentPojo);
		case SCHOOL_CALENDAR:
			return specschoolcalendar.getPreparedUpdate(con, tableName,
					oldPojo, currentPojo);
		default:
			return null;
		}


	}
	public static<T> T getPojoBySql(TableName tableName,ResultSet rs) 
			throws SQLException{
		switch (tableName){
		case STUDENT_TABLE:
			return (T)specstudent.getPojoBySql(rs);
		case IMAGE_TABLE:
			return (T)specimage.getPojoBySql(rs);
		case REQUEST_MESSAGE_TABLE:
			return (T)specrequestmessage.getPojoBySql(rs);
		case HOMEPAGE_IMAGE_TABLE:
			return (T)spechomepageimage.getPojoBySql(rs);
		case USER_TABLE:
			return (T)specuser.getPojoBySql(rs);
		case TEACHER_TABLE:
			return (T)specteacher.getPojoBySql(rs);
		case APPAPI_TABLE:
			return (T)specappapi.getPojoBySql(rs);
		case DEGRESS_TABLE:
			return (T)specdegress.getPojoBySql(rs);
		case ACLASS_TABLE:
			return (T)specaclass.getPojoBySql(rs);
		case POLITICAL_STATUS_TABLE:
			return (T)specpolitical.getPojoBySql(rs);
		case JOB_AUTHORITY_TABLE:
			return (T)specjobauthority.getPojoBySql(rs);
		case SCHOOL_NOTIFY_TABLE:
			return (T)specschoolnotify.getPojoBySql(rs);
		case SCHOOL_NOTIFY_IMAGE_TABLE:
			return (T)specschoolnotifyimage.getPojoBySql(rs);
		case RECEIVE_SCHOOL_NOTIFY_TABLE:
			return (T)specreceiveschoolnotify.getPojoBySql(rs);
		case PROFESSIONAL_TABLE:
			return (T)specprofessional.getPojoBySql(rs);
		case CLASS_NOTIFY_TABLE:
			return (T)specclassnotify.getPojoBySql(rs);
		case CLASS_NOTIFY_IMAGE_TABLE:
			return (T)specclassnotifyimage.getPojoBySql(rs);
		case RECEIVE_CLASS_NOTIFY_TABLE:
			return (T)specreceiveclassnotify.getPojoBySql(rs);
		case SCHOOL_TABLE:
			return (T)specschool.getPojoBySql(rs);
		case DEPARTMENT_TABLE:
			return (T)specdepartment.getPojoBySql(rs);
		case TEL_CONTACTS_TABLE:
			return (T)spetelcontacts.getLeftJoinPojo(rs);
		case SCHOOL_CALENDAR:
			return (T)specschoolcalendar.getLeftJoinPojo(rs);
		default:
			return null;
		}
	}
}
